/*#include "CanvasView.h"
#include "ToolFactory.h"
QString Canvas::currentTool;
Tool* aTool;
CanvasView::CanvasView(QWidget *parent)
: QGraphicsView(parent)

{ 
QGraphicsScene scene;
setAttribute (Qt::WA_SetCursor);

currentPixmap = new QGraphicsPixmapItem;
	ourCanvas = new Canvas;
	undoPointer = -1;
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);

}

void CanvasView::redo()
{
	int i = undoVector.size()-1;
	if(undoPointer < i)
	{
		++undoPointer;
		image = undoVector[undoPointer];
		this->resize(image->width(), image->height());
		this->updatePixmap();
	}

}


void CanvasView::saveUndoState()
{
	undoVector.push_back(new QImage(*image));
	undoPointer++;
}


void CanvasView::undo()
{
	if(undoPointer >= 0)
	{
		undoPointer--;
		image = undoPointer == -1 ? undoVector[undoPointer+1] : undoVector[undoPointer];
		this->updatePixmap();
		this->resize(image->width(), image->height());
		
	}


}
 void CanvasView::cleanUndoStack()
{

	for(int i = undoVector.size()-1;i > undoPointer;--i)
	{
		 delete undoVector[i];
		 undoVector.pop_back();
	}

}



QString getCurrentTool(){
	return Canvas::currentTool;
}

void CanvasView::updatePixmap()
{
	this->currentPixmap->setPixmap(QPixmap::fromImage(*image));

}
void CanvasView::mouseMoveEvent(QMouseEvent* event)
{
		if ((event->buttons() == Qt::LeftButton) && scribbling) 
			aTool->mouseMoveEvent(event, this);
}

void CanvasView::setImage(QImage* sourceImage)
{

	this->image = sourceImage;

	this->setScene(ourCanvas);
	this->currentPixmap->setPixmap(QPixmap::fromImage(*sourceImage));
	ourCanvas->addItem(currentPixmap);

}

void CanvasView::mouseReleaseEvent(QMouseEvent* event)
{
	     if (event->button() == Qt::LeftButton && scribbling) {
		     aTool->mouseReleaseEvent(event, this);

			  saveUndoState();
     }


}
void CanvasView::mousePressEvent(QMouseEvent* event)
{
     if (event->button() == Qt::LeftButton && getCurrentTool() != "") 
	 {
		 
		 if(undoVector.size()-1 > undoPointer)
			cleanUndoStack();

		 aTool = ToolFactory::createTool(getCurrentTool());
		 aTool->mousePressEvent(event, this);

	 }
}

void CanvasView::init(QImage image)
{
		


}*/